#include "../tools.h"



class MinStack {
private:
    stack<int> st1, st2;
public:
    /** initialize your data structure here. */
    MinStack() {

    }
    
    void push(int x) {
        st1.push(x);
        if(st2.empty()) st2.push(x);
        else if(x <= st2.top()) st2.push(x);
    }
    
    void pop() {
        if(!st2.empty() && st2.top() == st1.top()) st2.pop();
        st1.pop();
    }
    
    int top() {
        return st1.top();
    }
    
    int min() {
        return st2.top();
    }
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack* obj = new MinStack();
 * obj->push(x);
 * obj->pop();
 * int param_3 = obj->top();
 * int param_4 = obj->min();
 */



int main(int argc, char const *argv[])
{
    MinStack minStack;
    minStack.push(0);
    minStack.push(1);
    minStack.push(0);
    cout << minStack.min() << endl;     //--> 返回 -3.
    minStack.pop();
    // minStack.pop();     //--> 返回 0.
    cout << minStack.min() << endl;     //--> 返回 -2.


    return 0;
}
